﻿using Newtonsoft.Json.Linq;
using RestSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace StockTradier
{
    public partial class UserDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string accessToken = Request.Cookies["Info"]["accessToken"];

            RestClient client = new RestClient("https://api.tradier.com");
            var request = new RestRequest("/v1/user/balances", Method.GET);

            request.AddHeader("Authorization", "Bearer " + accessToken);
            var result = (client.Execute(request).Content);
            var json = JObject.Parse(result);
        }
    }

    public class UserBalance
    {
        public string AccountNumber { get; set; }
        public string AccountType { get; set; }
        public float ClosePl { get; set; }
        public float CurrentRequirement { get; set; }
        public float Equity { get; set; }
        public float LongMarketValue { get; set; }
        public float MarketValue { get; set; }
        public float OpenPl { get; set; }
        public float OptionLongValue { get; set; }
        public float OptionRequirement { get; set; }
        public float OptionShortValue { get; set; }
        public int PendingOrdersCount { get; set; }
        public float ShortMarketValue { get; set; }
        public float StockLongValue { get; set; }
        public float TotalCash { get; set; }
        public float TotalEquity { get; set; }
        public float UnclearedFunds { get; set; }
        public Margin Margin { get; set; }
        public PDT Pdt { get; set; }
    }


    public class Margin
    {
        public int FedCall { get; set; }
        public int MaintenanceCall { get; set; }
        public float OptionBuyingPower { get; set; }
        public float StockBuyingPower { get; set; }
        public int StockShortValue { get; set; }
        public int Sweep { get; set; }
    }

    public class PDT
    {
        public float DayTradeBuyingPower { get; set; }
        public int FedCall { get; set; }
        public int MaintenanceCall { get; set; }
        public float OptionBuyingPower { get; set; }
        public float StockBuyingPower { get; set; }
        public int StockShortValue { get; set; }
    }
}